package com.framework.webxml.controller;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("jsp")
public class JspController {


    @GetMapping("info")
    public String info(@RequestParam(value = "name",defaultValue = "zhangSan") String name, HttpServletRequest request) {
        // 将数据存储到[请求]共享域中，方便页面取值。
        request.setAttribute("name", name);
        // 从[会话域]中，获取值
        Object name1 = request.getSession().getAttribute("name");
        // 并传递到[请求域]中
        request.setAttribute("name1", name1);
        return "info";
    }
}
